home *** CD-ROM | disk | FTP | other *** search
Text File | 2005-12-18 | 47.7 KB | 1,554 lines |
- function IsMCEEnabled()
- {
- return true
- }
-
- function Initialize()
- {
- if (nCurFocus == "SVP" || nCurFocus == "CVP" )
- {
- return
- }
-
- SetFocus();
- }
-
-
- function Disable()
- {
- if (event.button == 2)
- try
- {
- window.external.MediaCenter.Dialog("right-click disabled","",1,30,true)
- }
- catch(e)
- {
- }
- }
-
-
- /////////////////////////////////////////////////////////////////
- // user selected item, navigate to it based on DestinationArray
- function DoNavigation()
- {
- // make sure focus is not on a viewport
- if ((nCurFocus == "SVP") || (nCurFocus == "CVP"))
- {
- return
- }
-
- try
- {
- // if array element is not empty
- if (aFocusTableArray[nCurFocus-1][10] != "")
- {
- try
- {
- // try to run as a function; if element string is a link instead of a function, create an error
- eval(aFocusTableArray[nCurFocus-1][10]);
-
- // If element is a link starting with "http" it will not cause error;
- // so check if string starts with "http"; if so, treat as a link
- try
- {
- var sArraySubStr = (aFocusTableArray[nCurFocus-1][10]).substring(0, 4)
- if (sArraySubStr == "http")
- {
- window.navigate(aFocusTableArray[nCurFocus-1][10]);
- }
- else
- {
- // Should keep navigation?
- }
- }
- catch(e)
- {
- // ignore error
- }
- }
- catch(e)
- {
- // if previous throws error, treat as a link
- window.navigate(aFocusTableArray[nCurFocus-1][10]);
- }
- }
- }
- catch(e)
- {
- //ignore error
- }
- }
-
-
- /////////////////////////////////////////////////////////////////
- // focus on item in list based on nCurFocus value and user input
- function SetFocus(nKey)
- {
- try
- {
- /////////////////////////////////////////////////////////////////////////////////
- // reset mouse variable to nullify mouseover event, which can fire after keypress
- nMouseEvent = 0;
-
- //////////////////////////////////////////////////////////////////////////////////
- // hold onto current focus in case it gets broken along the way
-
- var nPrevFocus = nCurFocus;
- //////////////////////////////////////////////////////////////////////////////////
- // update nCurFocus values based on key selection
- // on first visit to page, nothing to do because nCurFocus is initialized
-
- //first, check if previous focus is on a viewport
- if (nPrevFocus == "CVP")
- {
- // check correct array for new focus item
- nCurFocus = aCustomViewportArray[nKey];
- }
- else if (nPrevFocus == "SVP")
- {
- // check correct array for new focus item
- nCurFocus = aSharedViewportArray[nKey];
- }
- // if previous focus is not on a viewport, find new focus item in regular array
- else
- {
- if (nKey >= 0)
- nCurFocus = aFocusTableArray[nCurFocus-1][nKey];
-
- DontSetFocusOnSeparator(nKey);
- }
-
- //////////////////////////////////////////////////////////////////////////////////
- // user tried an illegal move, reset nCurFocus to known state
- if (nCurFocus == -1)
- {
- nCurFocus = nPrevFocus;
- strCurItemName = eval('item' + nCurFocus)
- if (eval(strCurItemName).scrollable == 'true')
- scrollElement(nCurFocus,nKey,17)
-
- return;
- }
-
- DrawFocus(nPrevFocus, nCurFocus, (nKey >= 0));
-
- // Check if a right buttonlist button was clicked
- if (nCurFocus > nOrdinaryItems)
- {
- var nIndex;
-
- aSharedViewportArray[3] = nCurFocus;
- for (nIndex = 1; nIndex <= nOrdinaryItems; nIndex++)
- aFocusTableArray[nIndex -1][3] = nCurFocus;
- }
- }
- catch(e)
- {
- //ignore error
- }
- }
-
-
- function DontSetFocusOnSeparator(nKey)
- {
- var sClass;
- var nSepFocus;
-
- try
- {
- sClass = eval('item' + nCurFocus + '.className');
- if(sClass == 'btnright_sep')
- {
- nSepFocus = nCurFocus;
-
- if(nKey == 0)
- {
- if(aFocusTableArray[nCurFocus-1][0] == -1)
- {
- scrollMenu(nCurFocus);
- nCurFocus = aFocusTableArray[nCurFocus-1][1];
- }
- else
- nCurFocus = aFocusTableArray[nCurFocus-1][0];
- }
- else
- nCurFocus = aFocusTableArray[nCurFocus-1][1];
-
- DrawFocus(nSepFocus, nCurFocus, false);
- }
- }
- catch(e)
- {
- }
- }
-
-
- /////////////////////////////////////////////////////////////////
- // DrawFocus
- function DrawFocus(nPrevFocus, nCurFocus, bPlaySound)
- {
- try
- {
- // if enforced item was clicked
- if (nPrevFocus == "ENF")
- {
- var enforcedCurrent = aFocusTableArray[nCurFocus-1][9];
-
- for (i=0; i < nOrdinaryItems; i++)
- {
- if (aFocusTableArray[i])
- {
- if (aFocusTableArray[i][9] == enforcedCurrent)
- eval('item' + (i + 1) + '.className=aFocusTableArray[i][5]')
-
- if (i == (nCurFocus - 1))
- eval('item' + (i + 1) + '.className=strEnforcedItemFocusStyle')
- }
- }
- }
- else if ((nPrevFocus == "SVP") || (nPrevFocus == "CVP"))
- {
- // remove focus from viewport
- if (nPrevFocus == "SVP")
- {
- try
- {
- // add code to remove focus from viewport (not supported yet)
- }
- catch(e)
- {
- //Viewport is hidden; ignore error
- }
- }
- if (nPrevFocus == "CVP")
- {
- try
- {
- // add code to remove focus from viewport (not supported yet)
- }
- catch(e)
- {
- //Viewport is hidden; ignore error
- }
- }
- }
- else
- {
- // remove focus from the previous item if different
- if (nPrevFocus != nCurFocus)
- {
- var strPrevItemName = eval('item' + nPrevFocus)
-
- // check if previous item is "enforced" (to indicate active category)
- try
- {
- if (strPrevItemName.id == strEnforcedItem)
- {
- eval(strPrevItemName).className = strEnforcedItemNoFocusStyle
- }
- else if (eval(strPrevItemName).checked != null)
- {
- if (eval(strPrevItemName).checked == 'yes')
- eval(strPrevItemName).className = aFocusTableArray[nPrevFocus-1][5] + '_checked';
- else
- eval(strPrevItemName).className = aFocusTableArray[PrevFocus-1][5];
- }
- else if (eval(strPrevItemName).trible != null)
- {
- eval(strPrevItemName).className=aFocusTableArray[nPrevFocus-1][5];
- body.focus();
- }
- else
- {
- if (eval(strPrevItemName).parentElement.className == 'btnMediaTD')
- {
- eval(strPrevItemName).parentElement.children(1).className = 'btnMediaText_nofocus';
- }
- eval(strPrevItemName).className=aFocusTableArray[nPrevFocus-1][5];
- }
- }
- catch(e)
- {
- eval(strPrevItemName).className=aFocusTableArray[nPrevFocus-1][5];
- }
- }
- }
-
- // Play "click" sound
- if (bPlaySound)
- playFocusSound();
-
- // set buttons in current array to non-dormant, and buttons in other
- // arrays to dormant
- setDormant(nCurFocus, nPrevFocus);
-
- // if new item is shared viewport
- if (nCurFocus == "SVP")
- {
- // check if shared viewport is visible
- try
- {
- if (window.external.MediaCenter)
- {
- if (window.external.MediaCenter.SharedViewPort.Visible == true)
- {
- window.external.MediaCenter.SharedViewPort.Focus()// focus on shared viewport
- }
- else
- {
- // viewport is hidden, so reset focus to backup item in viewport array, by setting nKey to 4
- SetFocus(4)
- }
- }
- else
- SetFocus(4);
- }
-
- catch(e)
- {
- SetFocus(4)
- }
-
- return
- }
- //if new item is custom viewport
- else if (nCurFocus == "CVP")
- {
- // check if custom viewport is visible
- try
- {
- if (window.external.MediaCenter.CustomViewPort.visible == true)
- {
- window.external.MediaCenter.CustomViewPort.Focus() // focus on custom viewport
- }
- else
- {
- // viewport is hidden, so reset focus to backup item in viewport array, by setting nKey to 4
- SetFocus(4)
- }
- }
-
- catch(e)
- {
- SetFocus(4)
- }
-
- return
- }
-
- // give focus to the new item
- var strNewItemName = eval('item' + nCurFocus)
- try
- {
- // if array element is not empty
- if (aFocusTableArray[nCurFocus-1][11] != null)
- {
- if (aFocusTableArray[nCurFocus-1][11] != "")
- {
- try
- {
- if (currentSelect)
- currentSelect.innerHTML = aFocusTableArray[nCurFocus-1][11];
- }
- catch(e)
- {
- // ignore error
- }
- }
- else
- {
- try
- {
- if (currentSelect)
- currentSelect.innerHTML = "";
- }
- catch(e)
- {
- // ignore error
- }
- }
- }
- else
- {
- try
- {
- if (currentSelect)
- currentSelect.innerHTML = "";
- }
- catch(e)
- {
- // ignore error
- }
- }
- if (aFocusTableArray[nCurFocus-1][12] != null)
- {
- if (aFocusTableArray[nCurFocus-1][12] != "")
- {
- try
- {
- if (currentSelectTagLine)
- currentSelectTagLine.innerHTML = aFocusTableArray[nCurFocus-1][12];
- }
- catch(e)
- {
- // ignore error
- }
- }
- else
- {
- if (currentSelectTagLine)
- currentSelectTagLine.innerHTML = "";
- }
- }
- else
- {
- if (currentSelectTagLine)
- currentSelectTagLine.innerHTML = "";
- }
- }
- catch(e)
- {
- // ignore error
- }
-
- // check if new item is "enforced" (to indicate active category)
- try
- {
- if (strNewItemName.id == strEnforcedItem)
- {
- eval(strNewItemName).className = strEnforcedItemFocusStyle
- }
- else if (eval(strNewItemName).checked != null)
- {
- if (eval(strNewItemName).checked == 'yes')
- eval(strNewItemName).className = aFocusTableArray[nCurFocus-1][4] + '_checked';
- else
- eval(strNewItemName).className = aFocusTableArray[nCurFocus-1][4];
- }
- else if (eval(strNewItemName).trible != null)
- {
- eval(strNewItemName).className = aFocusTableArray[nCurFocus-1][4];
- tribleTabControl.SetInputFocus();
- }
- else
- {
- if (eval(strNewItemName).parentElement.className == 'btnMediaTD')
- {
- eval(strNewItemName).parentElement.children(1).className = 'btnMediaText_focus';
- }
- eval(strNewItemName).className = aFocusTableArray[nCurFocus-1][4];
- }
- }
- catch(e)
- {
- eval(strNewItemName).className = aFocusTableArray[nCurFocus-1][4];
- }
-
- if (nCurFocus <= nOrdinaryItems)
- {
- if (aFocusTableArray[nPrevFocus-1])
- {
- if (aFocusTableArray[nPrevFocus-1][9] != '')
- {
- if (aFocusTableArray[nCurFocus-1][9] == '')
- {
- for (i=0; i < nOrdinaryItems; i++)
- {
- if (aFocusTableArray[i])
- {
- if (aFocusTableArray[i][9] == aFocusTableArray[nPrevFocus-1][9])
- {
- if ('item' + (i + 1) == strEnforcedItem)
- eval('item' + (i + 1) + '.className=\'btn_nofocus_enforced_notcurrent\'')
- else
- eval('item' + (i + 1) + '.className=\'btn_nofocus\'')
- }
- }
- }
- }
- }
- else
- {
- if (aFocusTableArray[nCurFocus-1][9] != '')
- {
- for (i=0; i < nOrdinaryItems; i++)
- {
- if (aFocusTableArray[i])
- {
- if (aFocusTableArray[i][9] == aFocusTableArray[nCurFocus-1][9])
- {
- if (i != (nCurFocus - 1))
- {
- if ('item' + (i + 1) == strEnforcedItem)
- eval('item' + (i + 1) + '.className=\'btn_nofocus_enforced\'')
- else
- eval('item' + (i + 1) + '.className=\'btn_nofocus_enforceGroup\'')
- }
- }
- }
- }
- }
- }
- }
- }
-
- // determine if the page has a scrolling menu
- try
- {
- if (strScrollPage == "yes")
- {
- scrollMenu(nCurFocus);
- }
- }
- catch (e)
- {
- //ignore error
- }
-
- // Custom (optional) function if needed; locate this function on the HTML page
- try
- {
- doOnFocus();
- }
- catch(e)
- {
- //ignore error
- }
- }
- catch(e)
- {
- //ignore error
- }
- }
-
-
- /////////////////////////////////////////////////////////////////
- // Scaling elements for page resize
- function onScaleEvent(vScale)
- {
- try
- {
- if (vScale != 1)
- document.styleSheets[0].href = 'cssscaled.css'
-
- body.style.zoom=vScale;
- }
- catch(e)
- {
- // ignore error
- }
- }
-
-
- /////////////////////////////////////////////////////////////////
- // determine which remote control key the user selected
- // and take appropriate action
- function onRemoteEvent(keyChar)
- {
- try
- {
- switch (keyChar)
- {
- case 0x26: // Up button selected
- if(pFocusOnTextFrame())
- pScrollTextframe(keyChar);
- else
- SetFocus(0);
- return true;
- break;
-
- case 0x28: // Down button selected
- if(pFocusOnTextFrame())
- pScrollTextframe(keyChar);
- else
- SetFocus(1);
- return true;
- break;
-
- case 0x25: // Left button selected
- SetFocus(2);
- return true;
- break;
-
- case 0x27: // Right button selected
- SetFocus(3);
- return true;
- break;
-
- case 0x0D: // Enter button selected, execute link to content/page
- DoNavigation();
- return true;
- break;
-
- case 0x08: // Keyboard Backspace selected
- return false;
- break;
- case 0xA6: // Browser Back button selected; Media Center will already perform a Back
- return false; // navigation when this is pressed, but this case can be used to add additional
- break; //functionality to Back button
-
- case 0x21: // Page up (plus) selected; page-up scrolling menu
- // (currently works for keyboard pg-up, but not for remote key)
- if(pFocusOnTextFrame())
- pScrollTextframe(keyChar);
- else
- pageUp();
- return true;
- break;
-
- case 0x22: // Page down (minus) selected; page-down scrolling menu
- // (currently works for keyboard pg-down, but not for remote key)
- if(pFocusOnTextFrame())
- pScrollTextframe(keyChar);
- else
- pageDown();
- return true;
- break;
-
- default:
- return false;
- // ignore all other clicks
- }
- }
- catch(ex)
- {
- logEx("onRemoteEvent(" + keyChar + ")", ex);
- }
- }
-
-
- function pFocusOnTextFrame()
- {
- var sClassname;
-
- sClassname = ""
- try
- {
- sClassname = eval("item" + nCurFocus + ".className");
- if(sClassname.substring(0, 9) == "TextFrame")
- return true;
- }
- catch(e)
- {
- }
-
- return false;
- }
-
-
- function pScrollTextframe(keyChar)
- {
- var nTop;
- var nHeight;
- var nLines;
-
- nTop = listTable.style.top;
- nTop = parseInt(nTop);
-
- nHeight = listTable.scrollHeight - listFrame.clientHeight;
-
- nPageHeight = Math.floor(listFrame.clientHeight / nScrollTextPixels) * nScrollTextPixels;
-
- switch(keyChar)
- {
- case 0x26: // arrow up
- nTop = nTop + nScrollTextPixels;
- break;
-
- case 0x28: // arrow down
- nTop = nTop - nScrollTextPixels;
- break;
-
- case 0x21: // page up
- nTop = nTop + nPageHeight;
- break;
-
- case 0x22: // page down
- nTop = nTop - nPageHeight;
- break;
- }
-
- if(nTop > 0)
- nTop = 0;
- if(nTop < -nHeight)
- if(nHeight > 0)
- nTop = -nHeight;
- else
- nTop = 0;
-
- listTable.style.top = nTop;
-
- resetScrollCounter();
- }
-
-
- function pGetScrollTotal()
- {
- var nHeight;
-
- nHeight = listTable.scrollHeight - listFrame.clientHeight;
- if(nHeight < 0)
- return 1;
- else
- return Math.ceil(nHeight / nScrollTextPixels + 1);
- }
-
-
- function pGetScrollPosition()
- {
- var nTop;
-
- nTop = listTable.style.top;
- nTop = parseInt(nTop);
-
- return Math.ceil(-nTop / nScrollTextPixels + 1);
- }
-
-
- function setScrollCounter()
- {
- // Make the scroll counter visible
- itemCounterSpan.style.display = "block";
-
- // Show total number of scrollable lines in the counter
- counterNum.innerText = 1;
- counterTotal.innerText = pGetScrollTotal();
-
- resetScrollCounter();
- }
-
-
- function resetScrollCounter()
- {
- var nPosition;
- var nTotal;
-
- // un-gray counter
- itemCounterSpan.style.filter = "alpha(opacity=100)";
- // display position of currently selected btn in counter
- nTotal = pGetScrollTotal();
- nPosition = pGetScrollPosition();
- counterNum.innerText = nPosition;
- // gray out up arrow if focus in on top button
- if (nPosition <= 1)
- {
- arrowUp.disabled = true;
- arrowUp.style.filter = "alpha(opacity=20)";
- }
- else
- {
- arrowUp.disabled = false;
- arrowUp.style.filter = "alpha(opacity=60)";
- }
- // gray out down arrow if focus in on bottom button
- if (nPosition == nTotal)
- {
- arrowDown.disabled = true;
- arrowDown.style.filter = "alpha(opacity=20)"
- }
- else
- {
- arrowDown.disabled = false;
- arrowDown.style.filter = "alpha(opacity=60)"
- }
- }
-
- /////////////////////////////////////////////////////////////////
- // SetCounter
- function setCounter()
- {
- //if page contains a scrolling button menu, set counter values
- if (strScrollPage == "yes")
- {
- // Make the menu's item counter visible
- itemCounterSpan.style.display = "block";
- // Show total number of buttons in menu
- counterNum.innerText = 1;
- counterTotal.innerText = eval(nTotalBtns);
- }
- }
-
-
- /////////////////////////////////////////////////////////////////
- // Sounds
- function playFocusSound()
- {
- btnSound.src = strFocusSound;
- }
-
- function scrollElement(nCurFocus,intDirection,moveSpeed)
- {
- if (intDirection == 1)
- {
- if (((currentViewingDescription.offsetHeight - currentViewingDescription.parentElement.offsetHeight) - -currentViewingDescription.offsetTop) > -moveSpeed)
- movePixels = moveSpeed;
- else
- movePixels = 0;
- }
- else
- {
- if (currentViewingDescription.offsetTop == 0)
- movePixels = 0;
- else
- movePixels = -moveSpeed;
- }
-
- currentViewingDescription.style.top = (currentViewingDescription.offsetTop - movePixels)
- }
-
- // ----------------- Start code to scroll menu ------------------
- function scrollMenu(nCurFocus)
- {
- var nFocusBtnRow
- //test for number of columns
- try
- {
- var nCols = nScrollMenuBtnCols
- }
- catch(e)
- {
- var nCols = 1
- }
-
- // if selected item button is not on the scrolling menu table, gray-out counter and end function
- if ((nCurFocus < nScrollMenuStartNo) || (nCurFocus > nScrollMenuEndNo))
- {
- var sClassname;
-
- sClassname = ""
- try
- {
- sClassname = eval("item" + nCurFocus + ".className");
- }
- catch(e)
- {
- }
- if(sClassname.substring(0, 9) != "TextFrame")
- {
- itemCounterSpan.style.filter = "alpha(opacity=50)";
- displayImages();
- }
- return;
- }
-
- // determine what position the current-focus button occupies in list table by
- // subtracting the number of buttons that occur on the page before the
- // menu starts (nScrollMenuStartNo - 1) from the item number
- // of the current-focus button (nCurFocus)
- var nFocusBtnPosition = (nCurFocus - (nScrollMenuStartNo - 1));
-
- // determine what row in list table current-focus button occupies
- if (Math.floor((nFocusBtnPosition) / nCols) < ((nFocusBtnPosition) / nCols))
- {
- nFocusBtnRow = (Math.floor((nFocusBtnPosition) / nCols) + 1)
- }
- else
- {
- nFocusBtnRow = ((nFocusBtnPosition) / nCols)
- }
-
- // reset counter
- resetCounter(nCurFocus);
-
- // set a variable for the current position (# of button spaces offset) of
- // the top of the list table
- var nTableTopPosition = (listTable.offsetTop / -(nBtnHeight));
-
- // determine whether the current-focus button is out of view, above or below; scroll accordingly
- if (nFocusBtnRow > (nVisibleBtns + nTableTopPosition))
- {
- if ((nFocusBtnRow - (nVisibleBtns + nTableTopPosition)) > 1)
- movePixels = ((nBtnHeight) * (nFocusBtnRow - (nVisibleBtns + nTableTopPosition))) + nBtnHeight
- else
- movePixels = (nBtnHeight) * (nFocusBtnRow - (nVisibleBtns + nTableTopPosition))
-
- // focus btn is below view, so scroll down
- listTable.style.top = (listTable.offsetTop - movePixels)
- displayImages();
- }
-
- if (nFocusBtnRow <= nTableTopPosition)
- {
- // focus btn is above view, so scroll up
- listTable.style.top = ((nFocusBtnRow - 1) * -(nBtnHeight))
- displayImages();
- }
- }
- // ----------------- End code to scroll menu ------------------
-
- function displayImages()
- {
- listTop = listTable.style.top
-
- if (!listTop)
- listTop = 0
- else
- listTop = parseInt(listTop)
-
- firstItem = ((-listTop / nBtnHeight) * nScrollMenuBtnCols) + 1;
-
- for (i = firstItem; i < firstItem + (nVisibleBtns * nScrollMenuBtnCols); i++)
- {
- currentImage = document.getElementById('thumbImage' + i);
-
- if (currentImage)
- {
- hiddenSrc = currentImage.hiddenSrc;
-
- currentImage.runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader()';
-
- itemFilter = currentImage.filters.item("DXImageTransform.Microsoft.AlphaImageLoader");
-
- if (itemFilter)
- {
- itemFilter.src = hiddenSrc;
- itemFilter.sizingMethod = 'scale';
- }
- }
-
- currentText = document.getElementById('mediaText' + i);
-
- if (currentText)
- {
- if (currentText.className != 'btnMediaText_focus')
- currentText.className = 'btnMediaText_nofocus';
- currentText.innerHTML = '<nobr>' + currentText.textValue + '</nobr>'
- }
- }
- }
-
-
- // ----------------- Start code to set non-selected menu to dormant ------------------
- function setDormant(nCurFocus, prevItemNo)
- // NOTE: this function does not work for every item; it is made to catch errors and ignore them
- {
- try
- {
- // if strDormantPage variable on HTML page is not set to "yes" then end function
- if (strDormantPage != 'yes')
- {
- return
- }
- }
- catch(e)
- {
- // ignore error
- }
-
- try
- {
- // find previous button
- var oPrevBtn = eval('item' + prevItemNo);
- // find outer tables for previous button
- var oPrevParentTable = oPrevBtn.parentElement.parentElement.parentElement.parentElement;
- }
- catch(e)
- {
- //ignore error
- // can't set previous item to dormant
- }
-
- try
- {
- // find current button
- var oCurrentBtn = eval('item' + nCurFocus);
- // find outer tables for current button
- var oCurParentTable = oCurrentBtn.parentElement.parentElement.parentElement.parentElement;
- }
- catch(e)
- {
- //ignore error
- // can't set current item to dormant
- }
-
- // if previous and current buttons are in the same table, do nothing
- try
- {
- if (oPrevParentTable == oCurParentTable)
- {
- return
- }
- }
- catch(e)
- {
- //ignore error
- }
-
- try
- {
- // set previous-table items to dormant
- if (oPrevBtn.scrollable != 'true')
- {
- if (aFocusTableArray[(prevItemNo-1)].length > 9)
- {
- var enforcedGroup = aFocusTableArray[(prevItemNo-1)][9];
-
- for (i=0; i < oPrevParentTable.cells.length; i++)
- {
- if (oPrevParentTable.cells(i).children(0))
- {
- if (oPrevParentTable.cells(i).children(0).className != '')
- {
- if(oPrevParentTable.cells(i).children(0).className.indexOf('_sep') < 0)
- oPrevParentTable.cells(i).children(0).className=aFocusTableArray[(prevItemNo-1)][6];
-
- if (nOrdinaryItems)
- {
- for (j=0; j < nOrdinaryItems; j++)
- {
- if (oPrevParentTable.cells(i).children(0).id == 'item' + (j + 1))
- {
- if (oPrevParentTable.cells(i).children(0).checked == "yes")
- oPrevParentTable.cells(i).children(0).className=aFocusTableArray[j][6] + '_checked';
- else
- oPrevParentTable.cells(i).children(0).className=aFocusTableArray[j][6];
- }
- }
- }
- }
- }
- }
- }
- }
- // reset type style in each cell
- oPrevParentTable.className=aFocusTableArray[(prevItemNo-1)][7];
- //if enforced item is in previous table, make it dormant too
- try
- {
- if(eval(strEnforcedItem).parentElement.parentElement.parentElement.parentElement == oPrevParentTable)
- {
- eval(strEnforcedItem).className = strEnforcedItemDormantStyle
- }
- if(eval(strSecondEnforcedItem).parentElement.parentElement.parentElement.parentElement == oPrevParentTable)
- {
- eval(strSecondEnforcedItem).className = strEnforcedItemDormantStyle
- }
- }
- catch(e)
- {
- //ignore error
- }
- }
- catch(e)
- {
- //ignore error
- }
-
- // set current button's menu to active (non-dormant)
- try
- {
- if (oCurrentBtn.scrollable != 'true')
- {
- for (i = 0; i < oCurParentTable.cells.length; i++)
- {
- if (oCurParentTable.cells(i).children(0))
- {
- if (oCurParentTable.cells(i).children(0).className != '')
- {
- if(oCurParentTable.cells(i).children(0).className.indexOf('_sep') < 0)
- oCurParentTable.cells(i).children(0).className=aFocusTableArray[(nCurFocus-1)][5];
-
- if (nOrdinaryItems)
- {
- for (j=0; j < nOrdinaryItems; j++)
- {
- if (oCurParentTable.cells(i).children(0).id == 'item' + (j + 1))
- {
- if (oCurParentTable.cells(i).children(0).checked == "yes")
- oCurParentTable.cells(i).children(0).className=aFocusTableArray[j][5] + '_checked';
- else
- {
- if (aFocusTableArray[j][9] != '')
- {
- if (aFocusTableArray[j][9] != aFocusTableArray[nCurFocus-1][9])
- {
- if ('item' + (j + 1) == strEnforcedItem)
- eval('item' + (j + 1) + '.className=\'btn_nofocus_enforced_notcurrent\'')
- else
- eval('item' + (j + 1) + '.className=\'btn_nofocus\'')
- }
- else
- {
- if ('item' + (j + 1) == strEnforcedItem)
- eval('item' + (j + 1) + '.className=\'btn_nofocus_enforced\'')
- else
- oCurParentTable.cells(i).children(0).className=aFocusTableArray[j][5];
- }
- }
- else
- oCurParentTable.cells(i).children(0).className=aFocusTableArray[j][5];
- }
- }
- }
- }
- }
- }
- }
- }
- // reset type style in all of parent table
- oCurParentTable.className=aFocusTableArray[(nCurFocus-1)][8];
- //if enforced item is in current table, make it active too
- try
- {
- if(eval(strEnforcedItem).parentElement.parentElement.parentElement.parentElement == oCurParentTable)
- {
- //eval(strEnforcedItem).className = strEnforcedItemNoFocusStyle
- }
- if(eval(strSecondEnforcedItem).parentElement.parentElement.parentElement.parentElement == oCurParentTable)
- {
- //eval(strSecondEnforcedItem).className = strEnforcedItemNoFocusStyle
- }
- }
- catch(e)
- {
- //ignore error
- }
- }
- catch(e)
- {
- //ignore error
- }
- }
- // ----------------- End code to set non-selected menu to dormant ------------------
-
-
- // ----------------- Start code to reset counter number values (for scrolling menus) ------------------
- function resetCounter(nCurFocus)
- {
- var nFocusBtnPosition = (nCurFocus - (nScrollMenuStartNo - 1));
- // un-gray counter
- itemCounterSpan.style.filter = "alpha(opacity=100)";
- // display position of currently selected btn in counter
- counterNum.innerText = eval(nFocusBtnPosition);
- // gray out up arrow if focus in on top button
- if (nCurFocus == nScrollMenuStartNo)
- {
- arrowUp.disabled = true;
- arrowUp.style.filter = "alpha(opacity=20)";
- }
- else
- {
- arrowUp.disabled = false;
- arrowUp.style.filter = "alpha(opacity=60)";
- }
- // gray out down arrow if focus in on bottom button
- if (nCurFocus == nScrollMenuEndNo)
- {
- arrowDown.disabled = true;
- arrowDown.style.filter = "alpha(opacity=20)"
- }
- else
- {
- arrowDown.disabled = false;
- arrowDown.style.filter = "alpha(opacity=60)"
- }
- }
- // ----------------- End code to reset counter number values ------------------
-
-
- // --------------- Start code for Paging up/down (for scrolling menus) ---------------------------
- try
- {
- var nPageDistance = ((nVisibleBtns * nBtnHeight) - nBtnHeight) // Maximum distance to scroll for one "page" increment
- }
- catch(e)
- {
- nPageDistance = 0;
- }
-
- function pageDown()
- {
- // test to see if focus is on a table that should scroll
- // NOTE: this test assumes that the ID for your scrolling table is "ListTable"
- try
- {
- // If ID for scrollong table is not "listTable" then return.
- if (eval("item" + nCurFocus).parentElement.parentElement.parentElement.parentElement.id != "listTable")
- {
- return
- };
- }
- catch(e)
- {
- return
- }
- // determine if listTable has cellspacing; will need to subtract extra spacing from bottom of table
- var nTablePadding = eval(listTable.getAttribute("cellspacing"));
- // variables
- nPageDistance = ((nVisibleBtns * nBtnHeight) - nBtnHeight); // Maximum distance to scroll for one "page" increment
-
- // if there is just one big selectable row showing at a time in the scrollable menu, treat paging down the same as
- // scrolling down one item at a time (call setFocus function, passing the down-arrow key code).
- if (nPageDistance < nBtnHeight)
- {
- SetFocus(1);
- return
- }
-
- var nMaxPageDistance = ((listTable.offsetHeight - nTablePadding) - nPageDistance); // Maximum total paging distance
- var nCurrentScrollAmnt = -listTable.offsetTop; // amount already scrolled
- //test for number of columns
- try
- {
- var nCols = nScrollMenuBtnCols
- }
- catch(e)
- {
- var nCols = 1
- }
-
- // if selected item button is not on the scrolling menu table, end function
- if ((nCurFocus < nScrollMenuStartNo) || (nCurFocus > nScrollMenuEndNo))
- {
- return
- }
-
- var nFocusBtnPosition = (nCurFocus - (nScrollMenuStartNo - 1));
-
- // determine what row in list table current-focus button occupies
- if (Math.floor((nFocusBtnPosition) / nCols) < ((nFocusBtnPosition) / nCols))
- {
- nFocusBtnRow = (Math.floor(nFocusBtnPosition / nCols) + 1)
- }
- else
- {
- nFocusBtnRow = ((nFocusBtnPosition) / nCols)
- }
- // determine last row in menu
- var nLastRow = Math.floor((nScrollMenuEndNo - (nScrollMenuStartNo - 1)) / nCols)
-
- if (Math.floor((nScrollMenuEndNo - (nScrollMenuStartNo - 1)) / nCols) < ((nScrollMenuEndNo - (nScrollMenuStartNo - 1)) / nCols))
- {
- nLastRow = ((Math.floor((nScrollMenuEndNo - (nScrollMenuStartNo - 1)) / nCols)) + 1)
- }
- else
- {
- nLastRow = ((nScrollMenuEndNo - (nScrollMenuStartNo - 1)) / nCols)
- }
- // find which column current focus btn is in (multiply number of previous row by # of columns, and subtract from nFocusBtnPosition)
- var nFocusCol = (nFocusBtnPosition - ((nFocusBtnRow - 1) * nCols));
- // bottom visible row
- var nBottomVisRowNo = ((nCurrentScrollAmnt / nBtnHeight) + nVisibleBtns);
- if (nBottomVisRowNo >= nLastRow)
- {
- nBottomVisRowNo = nLastRow;
- }
-
- // determine which button is in focus col of bottom visible row
- var nNewFocusPosition = (((nBottomVisRowNo -1) * nCols) + nFocusCol);
- var nNewFocusBtnNo = (nNewFocusPosition + (nScrollMenuStartNo - 1));
- if (nNewFocusBtnNo > nScrollMenuEndNo)
- {
- nNewFocusBtnNo = nScrollMenuEndNo;
- }
-
- // if menu has already scrolled to bottom, set focus to last button and end function
- if (listTable.offsetHeight <= ((nVisibleBtns * nBtnHeight) + nCurrentScrollAmnt + nTablePadding))
- {
- DrawFocus(nCurFocus, nNewFocusBtnNo, true);
- nCurFocus = nNewFocusBtnNo;
- DontSetFocusOnSeparator(1)
- //reset counter
- resetCounter (nCurFocus);
- return;
- }
-
- // If current-focus btn is not in bottom visible row, assign focus there, do resets, and end function
- if (nCurFocus != nNewFocusBtnNo)
- {
- DrawFocus(nCurFocus, nNewFocusBtnNo, true);
- nCurFocus = nNewFocusBtnNo;
- DontSetFocusOnSeparator(1)
- //reset counter
- resetCounter (nCurFocus);
- return
- }
-
- // move page down
- listTable.style.top = -(nCurrentScrollAmnt + nPageDistance);
- displayImages();
-
- // update variables
- nCurrentScrollAmnt = -listTable.offsetTop;
- nBottomVisRowNo = ((nCurrentScrollAmnt / nBtnHeight) + nVisibleBtns);
- if (nBottomVisRowNo >= nLastRow)
- {
- nBottomVisRowNo = nLastRow;
- }
-
- // update which button is in bottom visible row, focus col -- based on new position
- nNewFocusPosition = (((nBottomVisRowNo -1) * nCols) + nFocusCol);
- nNewFocusBtnNo = (nNewFocusPosition + (nScrollMenuStartNo - 1));
- if (nNewFocusBtnNo > nScrollMenuEndNo)
- {
- nNewFocusBtnNo = nScrollMenuEndNo;
- }
-
- //reset focus to bottom visible btn
- DrawFocus(nCurFocus, nNewFocusBtnNo, true);
- nCurFocus = nNewFocusBtnNo;
-
- DontSetFocusOnSeparator(1)
-
- //reset counter
- resetCounter (nCurFocus);
- }
-
-
- //----------------------------Page Up ---------------------------------------------
- function pageUp()
- {
- // test to see if focus is on a table that should scroll
- // NOTE: this test assumes that the ID for your scrolling table is "ListTable"
- try
- {
- // If ID for scrollong table is not "listTable" then return
- if (eval("item" + nCurFocus).parentElement.parentElement.parentElement.parentElement.id != "listTable")
- {
- return
- };
- }
- catch(e)
- {
- return
- }
-
- // In case any erroneous mouseover event calls useMouse function, set nMouseEvnet value to 0
- nMouseEvent = 0;
- // determine if listTable has cellspacing; will need to subtract extra spacing from bottom of table
- var nTablePadding = eval(listTable.getAttribute("cellspacing"));
- // variables
- nPageDistance = ((nVisibleBtns * nBtnHeight) - nBtnHeight); // Maximum distance to scroll for one "page" increment
-
- // if there is just one big selectable row showing at a time in the scrollable menu, treat paging up the same as
- // scrolling up one row at a time (to do this, call setFocus function, passing the up-arrow key code).
- if (nPageDistance < nBtnHeight)
- {
- SetFocus(0);
- return
- }
- var nMaxPageDistance = ((listTable.offsetHeight - nTablePadding) - nPageDistance); // Maximum total paging distance
- var nCurrentScrollAmnt = -listTable.offsetTop; // amount already scrolled
-
- //test for number of columns
- try
- {
- var nCols = nScrollMenuBtnCols;
- }
- catch(e)
- {
- var nCols = 1;
- }
-
- // if selected item button is not on the scrolling menu table, end function
- if ((nCurFocus < nScrollMenuStartNo) || (nCurFocus > nScrollMenuEndNo)){
- return;
- }
-
- var nFocusBtnPosition = (nCurFocus - (nScrollMenuStartNo - 1));
-
- // determine what row in list table current-focus button occupies
- if (Math.floor((nFocusBtnPosition) / nCols) < ((nFocusBtnPosition) / nCols))
- {
- nFocusBtnRow = (Math.floor(nFocusBtnPosition / nCols) + 1);
- }
- else
- {
- nFocusBtnRow = ((nFocusBtnPosition) / nCols);
- }
-
- // find which column current focus btn is in (multiply number of previous row by # of columns, and subtract from nFocusBtnPosition)
- var nFocusCol = (nFocusBtnPosition - ((nFocusBtnRow - 1) * nCols));
-
- // top visible row
- var nTopVisRowNo = ((nCurrentScrollAmnt / nBtnHeight) + 1);
-
- // determine which button is in target col of top visible row
- var nNewFocusPosition = (((nTopVisRowNo -1) * nCols) + nFocusCol);
-
- var nNewFocusBtnNo = (nNewFocusPosition + (nScrollMenuStartNo - 1));
-
- // if menu is already at top, set focus to top btn, reset counter, and end function
- if (listTable.offsetTop >= 0)
- {
- DrawFocus(nCurFocus, nNewFocusBtnNo, true);
- nCurFocus = nNewFocusBtnNo;
- DontSetFocusOnSeparator(0)
- resetCounter (nCurFocus);
- return;
- }
-
- // If focus is not on top visible button in column, assign focus there and end function
- if (nCurFocus != nNewFocusBtnNo)
- {
- DrawFocus(nCurFocus, nNewFocusBtnNo, true);
- nCurFocus = nNewFocusBtnNo;
- DontSetFocusOnSeparator(0)
- // reset counter
- resetCounter (nCurFocus);
- return;
- }
-
- // move page up
- if ((-nCurrentScrollAmnt + nPageDistance) < 0)
- {
- listTable.style.top = (-nCurrentScrollAmnt + nPageDistance);
- }
- else
- {
- listTable.style.top = 0;
- }
- displayImages();
-
- // update variables
- nCurrentScrollAmnt = -listTable.offsetTop;
- nTopVisRowNo = ((nCurrentScrollAmnt / nBtnHeight) + 1);
- nNewFocusPosition = (((nTopVisRowNo -1) * nCols) + nFocusCol);
- nNewFocusBtnNo = (nNewFocusPosition + (nScrollMenuStartNo - 1));
-
- //reset focus to top visible btn
- DrawFocus(nCurFocus, nNewFocusBtnNo, true);
- nCurFocus = nNewFocusBtnNo;
-
- DontSetFocusOnSeparator(0)
-
- //reset counter
- resetCounter (nCurFocus);
- }
- // --------------------------------- End code for Paging up/down ----------------------------------------------------
-
-
- //----------------------------- Start code for switching to mouse ------------------------------------
- function useMouse(newItem)
- {
- if (nMouseEvent == 0)
- {
- nMouseEvent = 1;
- return;
- }
- var nNewItemNo = (newItem.children(0).id).substring(4);
- var nPrevFocus = nCurFocus;
- nCurFocus = nNewItemNo;
- DrawFocus(nPrevFocus, nCurFocus, true);
- }
-
-
- // use if item is not in table
- function useMouse2(newItem)
- {
- if (nMouseEvent == 0)
- {
- nMouseEvent = 1;
- return;
- }
- var nNewItemNo = newItem.id.substring(4);
- var nPrevFocus = nCurFocus;
- nCurFocus = nNewItemNo;
- DrawFocus(nPrevFocus, nCurFocus, true);
- }
- //----------------------------- End of code for switching to mouse ------------------------------------
-
-
- // Temporary "highlight" effect when button is clicked state, or clicked state
- function btnHiLite (srcBtn, style)
- {
- try
- {
- if ((strEnforcedItem == srcBtn.id) && (window.event.type == 'mouseup'))
- {
- style = strEnforcedItemFocusStyle;
- }
- if ((strSecondEnforcedItem == srcBtn.id) && (window.event.type == 'mouseup'))
- {
- style = strEnforcedItemFocusStyle;
- }
- }
- catch(e)
- {
- }
- srcBtn.className = style;
- }
-
-
- // Set button for enforced state (add code as necessary)
- function btnEnforced(btn)
- {
- }
-
- //----------------------------- Start code for Spinner control ------------------------------------
- // args are: (string to indicate whether to move up or down, number to identify which spinner to set)
- function countSpinner(sPlusMinusStr, nSpinnerNumber)
- {
- // check for disabled button
- if (eval("item" + nCurFocus).disabled == true)
- {
- return
- }
-
- // determine which array to use
- var sCurrentArray = "aSpinnerArray" + nSpinnerNumber
- // determine which element is currently shown
- var nTempElementCount = eval("aSpinnerArray" + nSpinnerNumber).count
- // if user clicked Plus, move element count forward by one
- if (sPlusMinusStr == "plus")
- {
- nTempElementCount = nTempElementCount + 1
- }
- // if user clicked Minus, move element count back by one
- if (sPlusMinusStr == "minus")
- {
- nTempElementCount = nTempElementCount - 1
- }
-
- // Call function to set spinner text
- setSpinner(sCurrentArray, nSpinnerNumber, nTempElementCount)
-
- // disable plus/minus buttons as needed
- if (nTempElementCount >= eval(sCurrentArray).length -1)
- {
- // disable second button in span (should be plus button)
- eval("item" + nCurFocus).parentElement.children[1].disabled = true
- }
- else
- {
- // enable second button in span (should be plus button)
- eval("item" + nCurFocus).parentElement.children[1].disabled = false
- }
-
- if (nTempElementCount <= 0)
- {
- // disable first button in span (should be minus button)
- eval("item" + nCurFocus).parentElement.children[0].disabled = true
- }
- else
- {
- // enable first button in span (should be minus button)
- eval("item" + nCurFocus).parentElement.children[0].disabled = false
- }
-
- //reset element count
- eval(sCurrentArray).count = nTempElementCount;
- }
-
-
- /////////////////////////////////////////////////////////////////
- // setSpinner
- function setSpinner(sCurrentArray, nSpinnerNumber, nTempElementCount)
- {
- //determine which spinner box to update
- var oCurBox = eval("spinnerBox" + nSpinnerNumber)
- // update box text with contents of array element
- oCurBox.innerHTML = (eval(sCurrentArray)[nTempElementCount]);
- }
-
- function setBGColor()
- {
- try
- {
- window.external.MediaCenter.BGColor = "#0F4A96"
- }
- catch(ex)
- {
- }
- }
-